//
// OpenTemplate
// Copyright (c) 2006
// by OpenArrow Software ( http://www.openarrow.com )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;

namespace OpenArrow.Templating.Directives
{
    /// <summary>
    /// Provides an interface to a Directive
    /// </summary>
    /// <remarks>
    /// <para>
    /// A Directive is a section of a template that can influence the way the template is generated or compiled.
    /// In the <see cref="OpenArrow.Templating.Parsing.AspNetStyleTemplateParser"/>, a directive is contained between
    /// '&lt;%@' and '%&gt;' tags. The concept of an OpenTemplate Directive is similar to that of an ASP.Net Directive.
    /// In fact, every Template must have a "Template" Directive (<see cref="OpenArrow.Templating.Directives.TemplateDirective"/>)
    /// which specifies the core information about a Template. Other directives are listed below:
    /// <list type="table">
    /// <listheader>
    /// <term>Directive (Class)</term>
    /// <description>Description</description>
    /// </listheader>
    /// <item>
    /// <term>Template (<see cref="OpenArrow.Templating.Directives.TemplateDirective"/>)</term>
    /// <description>Provides basic information about the template, such as the namespace and class name of the generated class</description>
    /// </item>
    /// <item>
    /// <term>Import (<see cref="OpenArrow.Templating.Directives.ImportDirective"/>)</term>
    /// <description>Allows a template to import .Net namespaces for use in code</description>
    /// </item>
    /// <item>
    /// <term>Property (<see cref="OpenArrow.Templating.Directives.PropertyDirective"/>)</term>
    /// <description>Allows a template to define public properties in the generated class</description>
    /// </item>
    /// <item>
    /// <term>Reference (<see cref="OpenArrow.Templating.Directives.ReferenceDirective"/>)</term>
    /// <description>Allows a template to reference .Net Assemblies that are requried by the template code</description>
    /// </item>
    /// </list>
    /// </para>
    /// <para>
    /// Directives are parsed by the <see cref="OpenArrow.Templating.Parsing.ITemplateParser"/> during the Parse Phase and stored
    /// in the <see cref="OpenArrow.Templating.Parsing.ParsedTemplate"/>. The <see cref="OpenArrow.Templating.Directives.DirectiveManager"/>
    /// is responsible for maintaining a list of Directives and their names, as well as creating instances of the Directive class and
    /// mapping data to the properties of the Directive. During the Generation Phase, an 
    /// <see cref="OpenArrow.Templating.Compilation.ITemplateGenerator"/> implementation will execute the Directive by running the
    /// <see cref="Execute(DirectiveContext)"/>
    /// </para>
    /// </remarks>
    public interface IDirective
    {
        /// <summary>
        /// When implemented, gets or sets the line number on which the directive is located
        /// </summary>
        /// <remarks>This property can be used for Error Reporting as well as the generation of Line Pragmas in the generated source</remarks>
        int LineNumber { get; set; }

        /// <summary>
        /// When implemented, executes the Directive in the specified <see cref="OpenArrow.Templating.Directives.DirectiveContext"/>
        /// </summary>
        /// <param name="context">Context information for the execution of the directive</param>
        /// <exception cref="OpenArrow.Templating.ActionProblemsException">A large number of errors occurred in the operation and it had to be aborted</exception>
        /// <exception cref="ArgumentNullException"><paramref name="context"/> is <see langword="null"/></exception>
        void Execute(DirectiveContext context);
    }
}
